package com.sanlit.inv.controller;

import com.sanlit.inv.entity.User;
import com.sanlit.inv.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Collections;

/**
 * <p>
 * 用户 前端控制器
 * </p>
 *
 * @author junjie.li@aliyun.com
 * @since 2021-03-21
 */
@Api(tags = "用户")
@RestController
@RequestMapping("/inv/user")
public class UserController {

    @Autowired
    IUserService userService;

    @ApiOperation(value="添加用户", notes="")
    @GetMapping("/add")
    public void add(@RequestParam(name = "id")Long id) {
        User user = new User();
        user.setId(id);
        user.setMobile("18503859500");
        user.setName("李");
        userService.saveOrUpdateBatch(Collections.singletonList(user));
    }

    @ApiOperation(value="获取所有用户列表", notes="")
    @GetMapping("/find/{id}")
    public User findById(@PathVariable(value = "id")Long id) {
        return userService.getById(id);
    }


}
